/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author FIRE
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface BasPerson extends BasicModel<BasPerson> {
  code?: string; // 业务员编码
  name?: string; // 业务员名称
  refUser?: any; // 关联用户
}

export const basPersonList = (params?: BasPerson | any) =>
  defHttp.get<BasPerson>({ url: adminPath + '/bas/person/list', params });

export const basPersonListData = (params?: BasPerson | any) =>
  defHttp.post<Page<BasPerson>>({ url: adminPath + '/bas/person/listData', params });

export const basPersonForm = (params?: BasPerson | any) =>
  defHttp.get<BasPerson>({ url: adminPath + '/bas/person/form', params });

export const basPersonSave = (params?: any, data?: BasPerson | any) =>
  defHttp.postJson<BasPerson>({ url: adminPath + '/bas/person/save', params, data });

export const basPersonImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/person/importData',
      onUploadProgress,
    },
    params,
  );

export const basPersonDelete = (params?: BasPerson | any) =>
  defHttp.get<BasPerson>({ url: adminPath + '/bas/person/delete', params });
